﻿using System;
using System.Windows.Forms;

namespace Runner
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void logsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!ActivateMdiChildForm("LogView"))
            {
                LogView lv = new LogView();
                lv.MdiParent = this;
                lv.WindowState = FormWindowState.Maximized;
                lv.Show();
            }
        }

        private void serviceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!ActivateMdiChildForm("ServiceManager"))
            {
                ServiceManager sm = new ServiceManager();
                sm.MdiParent = this;
                sm.WindowState = FormWindowState.Maximized;
                sm.Show();
            }
        }

        private bool ActivateMdiChildForm(string formName)
        {
            bool fl = false;
            if (this.MdiChildren.Length > 0)
                foreach (Form f in this.MdiChildren)
                    if (f.Name == formName)
                    {
                        fl = true;
                        f.Activate();
                        break;
                    }
            return fl;
        }

        private void MainForm_Load(object sender, EventArgs e)
        {

        }
    }
}
